// Fill out your copyright notice in the Description page of Project Settings.


#include "ScreenLoading.h"

#include "Widgets/Notifications/SProgressBar.h"

void SScreenLoading::Construct(const FArguments& InArgs, const FString& InMapName)
{
	MapName = InMapName;
	ChildSlot
	[
		SNew(SProgressBar).Percent(this, &SScreenLoading::GetProgress)
	]
	[
		SNew(SImage)
	];
}


TOptional<float> SScreenLoading::GetProgress() const
{
	// 未开始或已结束时返回-1，加载中返回0 - 100
	const float LoadPercentage = GetAsyncLoadPercentage(*MapName);
	return LoadPercentage * 0.01;
}

